<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
          

          

 

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>上传文件</legend>
</fieldset> 
<button type="button" class="layui-btn" id="test3"><i class="layui-icon"></i>上传文件</button>
<div style="margin-top: 10px;">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>拖拽上传</legend>
</fieldset> 
 
<div class="layui-upload-drag" id="test10">
  <i class="layui-icon"></i>
  <p>点击上传，或将文件拖拽到此处</p>
</div>
 

  

 
          

<script>
layui.use(['upload','layer'], function(){
  var $ = layui.jquery
  ,upload = layui.upload
      ,layer = layui.layer;
layer.msg("hello");

  //指定允许上传的文件类型
  upload.render({
    elem: '#test3'
    ,url: '/dw/docmy/upload?ispublic=0'
    ,accept: 'file' //普通文件
    ,size:6000
    ,done: function(res){
      if (res.code==200){
          // 关闭当前窗口,刷新页面
          layer.msg("上传成功",function () {
              var index = parent.layer.getFrameIndex(window.name);

              parent.layer.close(index);
              parent.location.href="/dw/page/docmy";
          });
          // var index = parent.layer.getFrameIndex(window.name);
          //
          // parent.layer.close(index);
          // parent.location.href="/dw/page/docmy";

      }

    }
  });
  

  
  
  //拖拽上传
  upload.render({
    elem: '#test10'
    ,url: '/dw/docmy/upload?ispublic=0'
    ,accept: 'file' //普通文件
    ,size:6000
    ,done: function(res){
          if (res.code==200){
              // 关闭当前窗口,刷新页面
              layer.msg("上传成功");
              var index = parent.layer.getFrameIndex(window.name);
              parent.layer.close(index);
              parent.location.href="/dw/page/docmy";

          }
    }
  });
  
 
  
});
</script>

</body>

</html>